package net.sf.bluecove;

import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import org.bluecove.tester.log.Logger;

import net.sf.bluecove.Configuration;
import net.sf.bluecove.Switcher;
import net.sf.bluecove.se.BlueCoveSpecific;
import net.sf.bluecove.se.JavaSECommon;

/**
 * 
 * @author Symon
 * @version 1.26
 * 
 */
public class SwingtoothStart extends JFrame {

	private static final long serialVersionUID = 5055442276712787146L;

	public void windowClosing(WindowEvent w) {
		quit();
	}

	/** Creates new form SwingtoothStart */
	public SwingtoothStart() {
		initComponents();
		try {
			JavaSECommon.initOnce();
			updateStatus("Java Initialised");
			updateStatus("Ready to Search for" + newline + "Bluetooth Devices!");
		} catch (Exception e1) {
			e1.printStackTrace();
			updateStatus("Device unable to Initiate," + newline
					+ "please restart program");
		}
	}

	/**
	 * This method is called from within the constructor to Initialise the form.
	 */
	private void initComponents() {

		jPanel1 = new JPanel();
		resultsBox = new JTextPane();
		jScrollPane1 = new JScrollPane();
		resultsBox.setContentType("text/html");
		startConnection = new JButton();
		stopSearching = new JButton();
		title = new JLabel();
		quitApp = new JButton();
		infoLabel = new JLabel();
		infoUpdate = new JTextArea(5, 20);
		infoUpdate.setEditable(false);
		resultsBox.setEditable(false);
		jPanel2 = new JPanel();
		jLabel5 = new JLabel();
		jLabel3 = new JLabel();
		jLabel1 = new JLabel();
		jLabel7 = new JLabel();
		jLabel9 = new JLabel();
		jLabel10 = new JLabel();
		jLabel11 = new JLabel();
		jLabel12 = new JLabel();
		posit = new JLabel();
		render = new JLabel();
		jLabel13 = new JLabel();
		capture = new JLabel();
		jLabel14 = new JLabel();
		audio = new JLabel();
		jLabel15 = new JLabel();
		jLabel16 = new JLabel();
		tele = new JLabel();
		info = new JLabel();
		jLabel17 = new JLabel();
		obex = new JLabel();
		limDis = new JLabel();
		network = new JLabel();
		encryptYes = new JLabel();
		encryptNo = new JLabel();
		trustYes = new JLabel();
		trustNo = new JLabel();
		AuthnYes = new JLabel();
		jPanel3 = new JPanel();
		jScrollPane2 = new JScrollPane();
		jScrollPane1 = new JScrollPane();

		// Sets the boxes default to disabled
		stopSearching.setEnabled(false);
		startConnection.setEnabled(true);

		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent evt) {
				quitNet(evt);
			}
		});

		title.setFont(new Font("Arista 2.0 Alternate Light", 2, 36));
		title.setHorizontalAlignment(SwingConstants.CENTER);
		title.setText("Blueswing Management System");

		// JScrollPane scrollPane = new JScrollPane(resultsBox);
		resultsBox.setContentType("text/html");
		jScrollPane1.setViewportView(resultsBox);

		jLabel5.setFont(new Font("Tahoma", 0, 14));
		jLabel5.setText("Authenticated"); // NOI18N

		jLabel3.setFont(new Font("Tahoma", 0, 14));
		jLabel3.setText("Encrypted"); // NOI18N

		jLabel1.setFont(new Font("Tahoma", 0, 14));
		jLabel1.setText("Key:"); // NOI18N

		jLabel7.setFont(new Font("Tahoma", 0, 14));
		jLabel7.setText("Trusted"); // NOI18N

		jLabel9.setFont(new Font("Tahoma", 0, 14));
		jLabel9.setText("Object Exchange"); // NOI18N

		jLabel10.setFont(new Font("Tahoma", 0, 14));
		jLabel10.setText("Not Limited Discovery"); // NOI18N

		jLabel11.setFont(new Font("Tahoma", 0, 14));
		jLabel11.setText("Networking"); // NOI18N

		encryptYes.setIcon(createImageIcon("padlockSmall.jpg",
				"a Locked Device"));

		encryptNo.setIcon(createImageIcon("openLockSmall.jpg",
				"an Unlocked Device"));

		trustYes.setIcon(createImageIcon("tickSmall.jpg", "Trusted"));

		trustNo.setIcon(createImageIcon("incorrectSmall.jpg", "not trusted"));

		AuthnYes.setIcon(createImageIcon("authenticatedSmall.jpg",
				"an authenticated devices"));

		obex.setIcon(createImageIcon("obexSmall.jpg", "Object Transfer"));

		limDis.setIcon(createImageIcon("discoverySmall.jpg",
				"Not limited discovery"));

		network.setIcon(createImageIcon("network.gif", "network enabled"));

		posit.setIcon(createImageIcon("positioningSmall.jpg",
						"network enabled"));
		
		render.setIcon(createImageIcon("renderSmall.jpg", "render enabled"));
		
		capture.setIcon(createImageIcon("captureSmall.jpg", "capture enabled"));
		
		audio.setIcon(createImageIcon("audioSmall.jpg", "audio enabled"));
		
		tele.setIcon(createImageIcon("telephoneSmall.jpg", "telephone enabled"));
		
		info.setIcon(createImageIcon("infoSmall.jpg", "info enabled"));

		infoUpdate.setFont(new Font("Tahoma", 0, 12));
		infoUpdate.setBackground(getBackground());

		jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel12.setText("Positioning"); // NOI18N

		jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel13.setText("Rendering"); // NOI18N

		jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel14.setText("Capture"); // NOI18N

		jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel15.setText("Audio"); // NOI18N

		jLabel16.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel16.setText("Telephone"); // NOI18N

		jLabel17.setFont(new java.awt.Font("Tahoma", 0, 14));
		jLabel17.setText("Info"); // NOI18N

		GroupLayout jPanel2Layout = new GroupLayout(
				jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout
				.setHorizontalGroup(jPanel2Layout
						.createParallelGroup(
								GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addGap(21, 21, 21)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.LEADING)
														.addComponent(
																jLabel10,
																GroupLayout.Alignment.TRAILING)
														.addComponent(
																jLabel9,
																GroupLayout.Alignment.TRAILING)
														.addComponent(
																jLabel7,
																GroupLayout.Alignment.TRAILING)
														.addGroup(
																GroupLayout.Alignment.TRAILING,
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel1)
																		.addPreferredGap(
																				LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				jLabel3))
														.addComponent(
																jLabel5,
																GroupLayout.Alignment.TRAILING)
														.addComponent(
																jLabel11,
																GroupLayout.Alignment.TRAILING))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.LEADING)
														.addComponent(
																encryptYes)
														.addComponent(AuthnYes)
														.addComponent(trustYes)
														.addComponent(obex)
														.addComponent(limDis)
														.addComponent(network))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED,
												77, Short.MAX_VALUE)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.TRAILING)
														.addComponent(jLabel12)
														.addComponent(jLabel14)
														.addComponent(jLabel13)
														.addComponent(jLabel15)
														.addComponent(jLabel16)
														.addComponent(jLabel17))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.LEADING)
														.addComponent(render)
														.addComponent(posit)
														.addComponent(capture)
														.addComponent(audio)
														.addComponent(tele)
														.addComponent(info))
										.addContainerGap()));
		jPanel2Layout
				.setVerticalGroup(jPanel2Layout
						.createParallelGroup(
								GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel1)
														.addComponent(jLabel3)
														.addComponent(
																encryptYes)
														.addComponent(jLabel12)
														.addComponent(posit))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel7)
														.addComponent(trustYes)
														.addComponent(jLabel13)
														.addComponent(render))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.BASELINE)
														.addComponent(AuthnYes)
														.addComponent(jLabel5)
														.addComponent(capture)
														.addComponent(jLabel14))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel9)
														.addComponent(obex)
														.addComponent(audio)
														.addComponent(jLabel15))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																GroupLayout.Alignment.LEADING)
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel2Layout
																						.createParallelGroup(
																								GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel10)
																						.addComponent(
																								limDis))
																		.addPreferredGap(
																				LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel2Layout
																						.createParallelGroup(
																								GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel11)
																						.addComponent(
																								network)))
														.addGroup(
																jPanel2Layout
																		.createSequentialGroup()
																		.addGroup(
																				jPanel2Layout
																						.createParallelGroup(
																								GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								tele)
																						.addComponent(
																								jLabel16))
																		.addPreferredGap(
																				LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				jPanel2Layout
																						.createParallelGroup(
																								GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								jLabel17)
																						.addComponent(
																								info))))
										.addContainerGap(
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		infoLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
		infoLabel.setText("Info:"); // NOI18N

		quitApp.setFont(new java.awt.Font("Tahoma", 1, 12));
		quitApp.setForeground(new java.awt.Color(153, 0, 0));
		quitApp.setText("Quit"); // NOI18N
		quitApp.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				quitAppActionPerformed(evt);
			}
		});

		stopSearching.setFont(new java.awt.Font("Arial", 0, 14));
		stopSearching.setForeground(new java.awt.Color(204, 0, 0));
		stopSearching.setText("Stop Searching"); // NOI18N
		stopSearching.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				stopSearchingActionPerformed(evt);
			}
		});

		startConnection.setFont(new java.awt.Font("Arial", 0, 14));
		startConnection.setForeground(new java.awt.Color(51, 102, 0));
		startConnection.setText("Start Searching"); // NOI18N
		startConnection.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				startConnectionActionPerformed(evt);
			}
		});

		GroupLayout jPanel3Layout = new GroupLayout(
				jPanel3);
		jPanel3.setLayout(jPanel3Layout);
		jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(
				GroupLayout.Alignment.LEADING).addComponent(
				infoUpdate, GroupLayout.Alignment.TRAILING,
				GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
				.addGroup(
						jPanel3Layout.createSequentialGroup().addComponent(
								infoLabel).addContainerGap()).addComponent(
						stopSearching,
						GroupLayout.Alignment.TRAILING,
						GroupLayout.DEFAULT_SIZE, 131,
						Short.MAX_VALUE).addComponent(startConnection,
						GroupLayout.Alignment.TRAILING,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
				.addGroup(
						jPanel3Layout.createSequentialGroup()
								.addGap(34, 34, 34).addComponent(quitApp)
								.addContainerGap(38, Short.MAX_VALUE)));
		jPanel3Layout
				.setVerticalGroup(jPanel3Layout
						.createParallelGroup(
								GroupLayout.Alignment.LEADING)
						.addGroup(
								GroupLayout.Alignment.TRAILING,
								jPanel3Layout
										.createSequentialGroup()
										.addComponent(startConnection)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(stopSearching)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(quitApp)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED,
												47, Short.MAX_VALUE)
										.addComponent(infoLabel)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												infoUpdate,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE)
										.addGap(47, 47, 47)));

		jScrollPane2
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		resultsBox.setContentType("text/html");
		jScrollPane1.setViewportView(resultsBox);

		jScrollPane2.setViewportView(jScrollPane1);

		GroupLayout jPanel1Layout = new GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								GroupLayout.Alignment.LEADING)
						.addComponent(title,
								GroupLayout.DEFAULT_SIZE, 647,
								Short.MAX_VALUE)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addGap(2, 2, 2)
										.addComponent(
												jPanel3,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane2,
												GroupLayout.DEFAULT_SIZE,
												498, Short.MAX_VALUE)
										.addContainerGap())
						.addGroup(
								GroupLayout.Alignment.TRAILING,
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap(218, Short.MAX_VALUE)
										.addComponent(
												jPanel2,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE)
										.addGap(59, 59, 59)));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addComponent(title)
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																GroupLayout.Alignment.LEADING)
														.addComponent(
																jPanel3,
																GroupLayout.PREFERRED_SIZE,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																jScrollPane2,
																GroupLayout.DEFAULT_SIZE,
																250,
																Short.MAX_VALUE))
										.addPreferredGap(
												LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jPanel2,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE)));

		GroupLayout layout = new GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addComponent(
						jPanel1, GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
						.addContainerGap(GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(
				GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addComponent(
						jPanel1, GroupLayout.PREFERRED_SIZE,
						GroupLayout.DEFAULT_SIZE,
						GroupLayout.PREFERRED_SIZE)
						.addContainerGap(GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));

		this.setTitle("Blueswing Software");
		pack();
	}// </editor-fold>

	private static void startConnectionActionPerformed(ActionEvent evt) {

		stopSearching.setEnabled(true);
		startConnection.setEnabled(false);
		resultsBox.setText("");
		Switcher.startClient();
	}

	private void stopSearchingActionPerformed(ActionEvent evt) {
		Switcher.clientShutdown();
		updateStatus("Search Stopped");
		stopSearching.setEnabled(false);
		startConnection.setEnabled(true);
	}

	private void quitAppActionPerformed(ActionEvent evt) {
		quit();
	}

	private void quitNet(WindowEvent evt) {
		quit();
	}

	// Adds a comment to the status bar when this method is called.
	public static void updateStatus(String text) {

		if (text.contains("BluetoothStateException")) {
			textNew = text.split(":");
			for (int i = 0; i < textNew.length; i++) {
				if (i == 1) {
					updateStatus(textNew[i]);
				}
			}
			stopSearching.setEnabled(false);
			startConnection.setEnabled(true);
		} else {
			String textExisting = infoUpdate.getText();
			infoUpdate.setText("");
			infoUpdate.append(text + newline + textExisting);
			infoUpdate.selectAll();

			lineCount = getLineCount(infoUpdate);
			if (lineCount == 7) {
				textExisting = infoUpdate.getText();
				infoUpdate.setText("");
				infoUpdate.append(text);
				infoUpdate.selectAll();
			}
			// Make sure the new text is visible, even if there
			// was a selection in the text area.
			infoUpdate.setCaretPosition(infoUpdate.getDocument().getLength());
		}
		if (text.startsWith("Device inquiry took ")) {
			Switcher.clientShutdown();
			updateStatus("Search Stopped");
			stopSearching.setEnabled(false);
			startConnection.setEnabled(true);
		}
		if (text.equals("Client finished!")) {
			stopSearching.setEnabled(false);
			startConnection.setEnabled(true);
		}
	}

	public static int getLineCount(JTextArea infoUpdate) {
		boolean lineWrapHolder = infoUpdate.getLineWrap();
		infoUpdate.setLineWrap(false);
		double height = infoUpdate.getPreferredSize().getHeight();
		infoUpdate.setLineWrap(lineWrapHolder);
		double rowSize = height / infoUpdate.getLineCount();
		return (int) (infoUpdate.getPreferredSize().getHeight() / rowSize);
	}

	public static void deviceSend() {
		// List of devices declared in TestClientBluetoothInquirer
		String textExisting = resultsBox.getText();
		resultsBox.setText("");
		resultsBox
				.setText("<span style=\"font-size: 20pt\">"
						+ TestClientBluetoothInquirer.deviceName
						+ "</span>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.deviceIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.trustIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.encryptIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.authenIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.obexIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.discoveryIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.networkIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.positionIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.renderingIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.captureIconLoc)
						+ "\"/>"
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.audioIconLoc)
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.teleIconLoc)
						+ "<img src="
						+ SwingtoothStart.class
								.getResource(TestClientBluetoothInquirer.infoIconLoc)
						+ "\"/>" + "<br>" + textExisting);
		resultsBox.selectAll();
		resultsBox.setCaretPosition(resultsBox.getDocument().getLength());
	}

	/** Returns an ImageIcon, or null if the path was invalid. */
	protected static ImageIcon createImageIcon(String path, String description) {
		java.net.URL imgURL = SwingtoothStart.class.getResource(path);
		if (imgURL != null) {
			return new ImageIcon(imgURL, description);
		} else {
			System.err.println("Couldn't find file: " + path);
			updateStatus("Couldn't find file: " + path);
			return null;
		}
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				Logger.debug("Stated app");
				Logger.debug("OS:" + System.getProperty("os.name") + "|"
						+ System.getProperty("os.version") + "|"
						+ System.getProperty("os.arch"));
				Logger.debug("Java:" + System.getProperty("java.vendor") + " "
						+ System.getProperty("java.version") + " "
						+ System.getProperty("java.vm.version"));
				// Schedule a job for the event-dispatching thread:
				// creating and showing this application's GUI.

				new SwingtoothStart().setVisible(true);
			}
		});
	}

	// Variables declaration
	private JPanel jPanel1;
	private static JTextPane resultsBox;
	private static JButton startConnection;
	private static JButton stopSearching;
	private JButton quitApp;
	private JLabel title;
	private JLabel infoLabel;
	public static JTextArea infoUpdate;
	private JLabel AuthnYes;
	private JLabel encryptNo;
	private JLabel encryptYes;
	private JLabel jLabel1;
	private JLabel jLabel3;
	private JLabel jLabel5;
	private JLabel jLabel7;
	private JLabel jLabel9;
	private JLabel jLabel10;
	private JLabel jLabel11;
	private JPanel jPanel2;
	private JPanel jPanel3;
	private JLabel jLabel12;
	private JLabel jLabel13;
	private JLabel jLabel14;
	private JLabel jLabel15;
	private JLabel jLabel16;
	private JLabel jLabel17;
	private JScrollPane jScrollPane1;
	private JScrollPane jScrollPane2;
	private JLabel trustNo;
	private JLabel trustYes;
	private JLabel obex;
	private JLabel limDis;
	private JLabel network;
	private JLabel info;
	private JLabel audio;
	private JLabel capture;
	private JLabel render;
	private JLabel posit;
	private JLabel tele;

	// Strings
	public final static String newline = "\n";
	private static String[] textNew = new String[10];

	// Intergers
	// This variable is the amount of phones picked up in
	// TestClientBluetoothInquirer
	public static int phoneCount = 0;
	private static int lineCount = 0;

	// End of variables declaration

	private void quit() {
		Logger.debug("quit");
		Switcher.clientShutdown();
		Switcher.serverShutdown();
		Switcher.serverShutdownOnExit();

		Rectangle b = this.getBounds();
		Configuration.storeData("main.x", String.valueOf(b.x));
		Configuration.storeData("main.y", String.valueOf(b.y));
		Configuration.storeData("main.height", String.valueOf(b.height));
		Configuration.storeData("main.width", String.valueOf(b.width));

		// Logger.removeAppender(this);
		BlueCoveSpecific.removeAppender();

		// this.dispose();
		System.exit(0);
	}
}
